package com.uestc.simchat;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import com.hyphenate.EMCallBack;
import com.hyphenate.chat.EMClient;

public class MainActivity extends AppCompatActivity {

    private EditText friendNameView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        friendNameView = (EditText) findViewById(R.id.sc_edit_friendname);

        findViewById(R.id.sc_btn_launch_chat).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {



                Intent intent = new Intent(MainActivity.this,SCChatActivity.class);
                //传入参数，账号，密码   //username、password是跳转目标页面获取它的参数   UserName、UserPassword是要传入的参数
                intent.putExtra("username",friendNameView.getText().toString().trim());
                startActivity(intent);

            }
        });

        findViewById(R.id.sc_btn_quit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //true表示退出时解绑设备
                EMClient.getInstance().logout(true);
                startActivity(new Intent(MainActivity.this, SCLoginActivity.class));
                finish();
            }
        });


    }
}